from django.utils import timezone
from django.db import models


class RbacUser(models.Model):
    id = models.BigAutoField(primary_key=True, verbose_name='ID')

    create_time = models.DateTimeField(default=timezone.now, verbose_name='创建时间')
    modify_time = models.DateTimeField(default=timezone.now, verbose_name='修改时间')
    is_delete = models.SmallIntegerField(default=0, verbose_name='是否删除，1：已删除，0未删除')
    version = models.IntegerField(default=1, verbose_name='版本')

    username = models.CharField(max_length=64, unique=True, verbose_name='用户名')
    password = models.CharField(max_length=68, verbose_name='密码')
    mobile = models.CharField(max_length=16, null=True, blank=True, verbose_name='手机号')
    status = models.SmallIntegerField(null=True, blank=True, verbose_name='账号是否锁定，1：启用，0: 禁用 2: 离职')
    avatar = models.CharField(max_length=500, null=True, blank=True, verbose_name='用户头像')
    email = models.CharField(max_length=100, null=True, blank=True, verbose_name='邮箱')
    remark = models.CharField(max_length=255, null=True, blank=True, verbose_name='备注')
    real_name = models.CharField(max_length=64, null=True, blank=True, verbose_name='姓名')

    creator = models.CharField(max_length=32, default='', blank=True, verbose_name='创建人')
    updater = models.CharField(max_length=32, default='', blank=True, verbose_name='编辑人')
    tenant_id = models.BigIntegerField(default=0, verbose_name='租户ID')

    validity_period_begin = models.DateField(null=True, blank=True, verbose_name='有效期开始')
    validity_period_end = models.DateField(null=True, blank=True, verbose_name='有效期结束')
    document_type = models.SmallIntegerField(null=True, blank=True, verbose_name='证件类型：0 未知 1 身份证')
    document_number = models.CharField(max_length=255, null=True, blank=True, verbose_name='证件号码')
    employee_number = models.CharField(max_length=255, null=True, blank=True, verbose_name='工号')
    contact_address = models.CharField(max_length=255, null=True, blank=True, verbose_name='联系地址')

    class Meta:
        db_table = "rbac_user"
        verbose_name = 'rbac_user'
        verbose_name_plural = verbose_name
